cInventory = {}
cInventory.Visible = false
cInventory.Width = ScrW()/4
cInventory.Height = ScrH()/3
cInventory.X	= 0
cInventory.Y = 0
cInventory.Title = ""
cInventory.Items = {}

function cInventory:Init()
	self.Items = {}
	self.Visible = false
	self.Title = ""
end

function cInventory:AddItem(item)
	local itm = vgui.Create("cSpawnIcon", self)
	local t = table.Random(TURRETS.AllTurrets)		
	local x,y = #self.Items*(64+8) + 16, 16 
	itm:SetPos(x,y)
	itm:SetSize(64,64)	
	itm:SetImage("gui/nonsense/icons/"..t.Icon)
	--itm:SetImage(ITEMS.AllItems[itm].Icon)
	itm:SetVisible(true)

	self.Items[#self.Items+1] = itm
end

function cInventory:Register(w,h,x,y)
	self.Width = w
	self.Height = h
	self.X = x
	self.Y = y
end

function cInventory:SetVisible(bool)
	if not type(bool) == "boolean" then return end
	self.Visible = bool
	gui.EnableScreenClicker( bool )
end

function cInventory:SetTitle(title)
	self.Title = title
end

function cInventory:DrawMenu()	
	-- draw the main rectangle
	surface.SetDrawColor( 0,0,0,235 )
	surface.DrawRect( 0, 0, self.Width, self.Height )
	
	-- draw the white outline
	surface.SetDrawColor( 255, 255, 255, 250 )
	surface.DrawOutlinedRect( 0, 0, self.Width, self.Height)
	
	-- create a close button
	if not self.closeButton then
		self.closeButton = vgui.Create("cCloseButton", self)
		self.closeButton:SetImage("gui/nonsense/close2")
		self.closeButton:SetPos(self.X+self.Width-16-9,self.Y+9)			
		self.closeButton:SetSize(16,16)
		self.closeButton:SetVisible(true)
	end	
end

function cInventory:Paint()	
	if (self.Visible == true) then	
		self:DrawMenu()	
	end
	return true
end
		
vgui.Register("cInventory", cInventory, "Panel")